Skip to content

Conversation

@ab-ghosh
Copy link
Member

  • Add case for 'cancelled' conclusion in GitLab provider CreateStatus
  • Map 'cancelled' to 'canceled' for GitLab API compatibility
  • Add unit test to verify cancelled status handling

📝 Description of the Change

👨🏻‍ Linked Jira

https://issues.redhat.com/browse/SRVKP-9050

🔗 Linked GitHub Issue

Fixes #

🚀 Type of Change

  • 🐛 Bug fix (fix:)
  • ✨ New feature (feat:)
  • 💥 Breaking change (feat!:, fix!:)
  • 📚 Documentation update (docs:)
  • ⚙️ Chore (chore:)
  • 💅 Refactor (refactor:)
  • 🔧 Enhancement (enhance:)
  • 📦 Dependency update (deps:)

🧪 Testing Strategy

  • Unit tests
  • Integration tests
  • End-to-end tests
  • Manual testing
  • Not Applicable

🤖 AI Assistance

  • I have not used any AI assistance for this PR.
  • I have used AI assistance for this PR.

If you have used AI assistance, please provide the following details:

Which LLM was used?

  • GitHub Copilot
  • ChatGPT (OpenAI)
  • Claude (Anthropic)
  • Cursor
  • Gemini (Google)
  • Other: ____________

Extent of AI Assistance:

  • Documentation and research only
  • Unit tests or E2E tests only
  • Code generation (parts of the code)
  • Full code generation (most of the PR)
  • PR description and comments
  • Commit message(s)

Important

If the majority of the code in this PR was generated by an AI, please add a Co-authored-by trailer to your commit message.
For example:

Co-authored-by: Gemini [email protected]
Co-authored-by: ChatGPT [email protected]
Co-authored-by: Claude [email protected]
Co-authored-by: Cursor [email protected]
Co-authored-by: Copilot [email protected]

**💡You can use the script ./hack/add-llm-coauthor.sh to automatically add
these co-author trailers to your commits.

✅ Submitter Checklist

  • 📝 My commit messages are clear, informative, and follow the project's How to write a git commit message guide. The Gitlint linter ensures in CI it's properly validated
  • ✨ I have ensured my commit message prefix (e.g., fix:, feat:) matches the "Type of Change" I selected above.
  • ♽ I have run make test and make lint locally to check for and fix any
    issues. For an efficient workflow, I have considered installing
    pre-commit and running pre-commit install to
    automate these checks.
  • 📖 I have added or updated documentation for any user-facing changes.
  • 🧪 I have added sufficient unit tests for my code changes.
  • 🎁 I have added end-to-end tests where feasible. See README for more details.
  • 🔎 I have addressed any CI test flakiness or provided a clear reason to bypass it.
  • If adding a provider feature, I have filled in the following and updated the provider documentation:
    • GitHub App
    • GitHub Webhook
    • Gitea/Forgejo
    • GitLab
    • Bitbucket Cloud
    • Bitbucket Data Center

@gemini-code-assist
Copy link

Summary of Changes

Hello @ab-ghosh, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue where the GitLab provider did not correctly interpret the 'cancelled' status. It introduces a specific case to map 'cancelled' to 'canceled' for GitLab API compatibility and sets an appropriate status title. A corresponding unit test has been added to ensure the new handling works as expected.

Highlights

  • GitLab Status Handling: Added explicit handling for the 'cancelled' status within the GitLab provider's CreateStatus function.
  • API Compatibility: Mapped the 'cancelled' conclusion to 'canceled' to ensure proper compatibility with the GitLab API.
  • Unit Testing: Included a new unit test to verify that the 'cancelled' status is correctly processed and mapped.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@pipelines-as-code
Copy link

pipelines-as-code bot commented Oct 14, 2025

🔍 PR Lint Feedback

Note: This automated check helps ensure your PR follows our contribution guidelines.

⚠️ Items that need attention:

🤖 AI attribution

The following commits lack an explicit AI attribution footer:

  • 8bb9a66 fix(gitlab): add explicit mapping for cancelled status
  • b040b54 chore(linter): enforce British spelling 'cancelled' over 'canceled'

If no AI assistance was used for a commit, you can ignore this warning.
Otherwise add an Assisted-by: or Co-authored-by: footer referencing the AI used.


ℹ️ Next Steps

  • Review and address the items above
  • Push new commits to update this PR
  • This comment will be automatically updated when issues are resolved
🔧 Admin Tools (click to expand)

Automated Issue/Ticket Creation:

  • /issue-create - Generate a GitHub issue from this PR content using AI
  • /jira-create - Create a SRVKP Jira ticket from this PR content using AI

⚠️ Important: Always review and edit generated content before finalizing tickets/issues.
The AI-generated content should be used as a starting point and may need adjustments.

These commands are available to maintainers and will post the generated content as PR comments for review.

🤖 This feedback was generated automatically by the PR CI system

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly adds support for the 'cancelled' status in the GitLab provider by mapping it to 'canceled' for API compatibility, and includes a unit test to verify the new logic. The implementation is sound. I have one suggestion to refactor the code slightly by combining similar cases, which would improve code clarity and maintainability.

@chmouel
Copy link
Member

chmouel commented Oct 14, 2025

can we fix canceled across the codebase ?

@ab-ghosh
Copy link
Member Author

I've reviewed the codebase and didn't find any other inconsistencies related to the use of “canceled” for GitLab.

@zakisk
Copy link
Contributor

zakisk commented Oct 14, 2025

can we fix canceled across the codebase ?

@chmouel what do you mean by fixing? removing?

Copy link
Contributor

@theakshaypant theakshaypant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feel free to resolve the comment if it is incorrect, added the comment more for learning for myself.

@ab-ghosh
Copy link
Member Author

Hi @chmouel @zakisk ,could you please confirm if any further changes are needed, or can we proceed with merging this PR?

@zakisk
Copy link
Contributor

zakisk commented Oct 23, 2025

Hi @chmouel @zakisk ,could you please confirm if any further changes are needed, or can we proceed with merging this PR?

E2E tests are not running for you and we're adding membership check in this PR #2285 after its CI succeeds we can merge it, and then you need to rebase with main

@zakisk
Copy link
Contributor

zakisk commented Oct 23, 2025

Or I will go with failed CI as well because its just workflow yaml changes doesn't affect E2E anyway

@chmouel
Copy link
Member

chmouel commented Oct 23, 2025

Bear in mind working on it, this PR make a good use case for user permission test and need to iterate with it

@chmouel
Copy link
Member

chmouel commented Oct 23, 2025

can we fix canceled across the codebase ?

@chmouel what do you mean by fixing? removing?

@zakisk i mean this

% rg --no-heading -n  --hidden --color=always --hyperlink-format=kitty -w canceled
.vale/styles/RedHat/TermsErrors.yml:98:  cancelled: canceled
docs/content/docs/guide/running.md:167:Older `PipelineRuns` are canceled only after the latest `PipelineRun` is
docs/content/docs/guide/running.md:172:the `PipelineRun` will be canceled.
test/gitlab_merge_request_test.go:363:	runcnx.Clients.Log.Infof("Waiting for old pipelinerun to be canceled")
test/gitlab_merge_request_test.go:432:	assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
test/gitlab_merge_request_test.go:600:		case "failed", "canceled", "skipped":
test/github_pullrequest_test.go:342:	g.Cnx.Clients.Log.Infof("Sleeping for 10 seconds to let the pipelinerun to be canceled")
test/github_pullrequest_test.go:360:				g.Cnx.Clients.Log.Infof("PipelineRun %s has been canceled", pr.Name)
test/github_pullrequest_test.go:403:	g.Cnx.Clients.Log.Infof("Sleeping for 10 seconds to let the pipelinerun to be canceled")
test/github_pullrequest_test.go:406:	g.Cnx.Clients.Log.Infof("Checking that the pipelinerun has been canceled")
test/github_pullrequest_test.go:412:	assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
test/github_pullrequest_retest_test.go:125:	// go over all pruns check that at least one is canceled and the other two are succeeded
test/github_pullrequest_retest_test.go:143:	assert.Equal(t, canceledCount, 1, "should have one canceled PipelineRun")
test/gitea_test.go:543:	assert.Equal(t, cancelledPr, 1, "only one pr should have been canceled")
test/gitea_test.go:557:	assert.Equal(t, cancelledPr, 2, "tweo pr should have been canceled")
test/gitea_test.go:589:	topts.ParamsRun.Clients.Log.Info("Waiting 10 seconds to check things has been canceled")
test/gitea_test.go:596:	assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
pkg/reconciler/reconciler.go:109:	// if status is not pending, it could be canceled so let it be reported, even if state is queued
pkg/provider/gitlab/gitlab.go:261:		statusOpts.Conclusion = "canceled"
pkg/provider/gitlab/gitlab.go:264:		statusOpts.Conclusion = "canceled"
test/github_push_retest_test.go:175:	g.Cnx.Clients.Log.Infof("Waiting for Repository to be updated still to %d since it has been canceled", numberOfStatus)
test/github_push_retest_test.go:176:	repo, _ := twait.UntilRepositoryUpdated(ctx, g.Cnx.Clients, waitOpts) // don't check for error, because canceled is not success and this will fail
test/bitbucket_cloud_pullrequest_test.go:101:	runcnx.Clients.Log.Info("Waiting 10 seconds to check things has been canceled")
test/bitbucket_cloud_pullrequest_test.go:108:	assert.Equal(t, prs.Items[0].GetStatusCondition().GetCondition(apis.ConditionSucceeded).GetReason(), "Cancelled", "should have been canceled")
pkg/cmd/tknpac/resolve/basic_auth_secret.go:80:			return "", "", fmt.Errorf("canceled")
pkg/cmd/tknpac/resolve/basic_auth_secret.go:85:				return "", "", fmt.Errorf("canceled")
.git/rr-cache/7b611ee6fa553aab35fbe2bc83c3d19bbdac9eff/postimage:261:		statusOpts.Conclusion = "canceled"
.git/rr-cache/7b611ee6fa553aab35fbe2bc83c3d19bbdac9eff/postimage:264:		statusOpts.Conclusion = "canceled"
.git/rr-cache/7b611ee6fa553aab35fbe2bc83c3d19bbdac9eff/preimage:261:		statusOpts.Conclusion = "canceled"
.git/rr-cache/7b611ee6fa553aab35fbe2bc83c3d19bbdac9eff/preimage:264:		statusOpts.Conclusion = "canceled"
󰘬 ~/git/pac/trees/main main ≡1                                                                                              

I thought we just standardize everywhere on the american wording (cancelled) instead of using canceled

@zakisk
Copy link
Contributor

zakisk commented Oct 23, 2025

@zakisk i mean this

ah, okay makes sense!

@zakisk
Copy link
Contributor

zakisk commented Oct 23, 2025

I thought we just standardize everywhere on the american wording (cancelled) instead of using canceled

@ab-ghosh feel free to find and change the docs/log messages having "canceled"

@chmouel
Copy link
Member

chmouel commented Oct 23, 2025

We need to figure out how to get the misspelling linter, or via golangci-lint, to flag for us some specific words used. I think it's possible if you can try to investigate that; that would be great, Abishek 🙏🏻

@theakshaypant
Copy link
Contributor

We need to figure out how to get the misspelling linter, or via golangci-lint, to flag for us some specific words used. I think it's possible if you can try to investigate that; that would be great, Abishek 🙏🏻

I think this might be helpful.

@ab-ghosh
Copy link
Member Author

I think this might be helpful.

@theakshaypant Yes, this should work, I was trying this.

@ab-ghosh ab-ghosh force-pushed the fix/gitlab-canceled-status-mapping branch 2 times, most recently from 7133c5c to 922f701 Compare October 24, 2025 07:42
.golangci.yml Outdated
- linters:
- misspell
path: pkg/provider/gitlab/gitlab\.go
text: '`canceled` is a misspelling of `cancelled`'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: '`canceled` is a misspelling of `cancelled`'
text: 'found `canceled` it must be `cancelled`'

you can't say that its misspelled as its just a other dialect of English some might choose to write 🙂

Copy link
Member

@chmouel chmouel Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe better:

use american english version of the word `cancelled` as `canceled` with one L

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zakisk this text field in the exclusion rule is not a custom message, it needs to exactly match the error message generated by the misspell linter itself. This is because golangci-lint uses it to pattern match against the linter's output when applying exclusions. In this case, I'm trying to exclude the files related to GitLab.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, yeah I didn't know that but in that can you can suppress the lint on CreateStatus func in gitlab.go using comment on it //nolint:misspell

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @zakisk! I will suppress the lint just for that function.

.golangci.yml Outdated
- linters:
- misspell
path: test/gitlab.*\.go
text: '`canceled` is a misspelling of `cancelled`'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@ab-ghosh ab-ghosh force-pushed the fix/gitlab-canceled-status-mapping branch from 922f701 to 9787dcc Compare October 26, 2025 18:03
@zakisk
Copy link
Contributor

zakisk commented Oct 27, 2025

/test

- Add case for 'cancelled' conclusion in GitLab provider CreateStatus
- Map 'cancelled' to 'canceled' for GitLab API compatibility
- Set descriptive title 'cancelled validating this commit'
- Ensures proper status reporting when PipelineRuns are cancelled via PR close
Add misspell linter configuration to enforce consistent use of
'cancelled' (British spelling) across the codebase. Update all
internal code, comments, and test assertions to use 'cancelled'.

Exclude GitLab provider code and test files from this rule, as
GitLab's API requires 'canceled' (American spelling) for
compatibility.

Changes:
- Configure misspell linter in .golangci.yml
- Fix spelling in pkg/cmd/tknpac and pkg/reconciler
- Update test files to use 'cancelled'
- Add exclusions for GitLab API-related code

Signed-off-by: ab-ghosh <[email protected]>
@zakisk zakisk force-pushed the fix/gitlab-canceled-status-mapping branch from 9787dcc to b040b54 Compare October 27, 2025 04:49
@zakisk zakisk merged commit 8a3103c into openshift-pipelines:main Oct 27, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants